package com.sdcx.agrobank.util;

import android.app.Application;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Typeface;




public class App extends Application {
    public static Context context;
    // public static IWXAPI mWxApi;
    public static final String APP_ID = "";
    public static String file= "fonts/source_h.otf";
    public static Typeface asset;

    @Override
    public void onCreate() {
        super.onCreate();

        this.context = getBaseContext();
        sApp = this;
      //  Fresco.initialize(this);
        //  registerToWX();
       // asset = Typeface.createFromAsset(getAssets(), App.file);
        Density.setDensity(this);
/*
        ViewPump.init(ViewPump.builder()
                .addInterceptor(new CalligraphyInterceptor(
                        new CalligraphyConfig.Builder()
                                .setDefaultFontPath(file)
                                //.setFontAttrId(R.attr.fontPath)
                                .build()))
                .build());
*/
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        if (newConfig.fontScale != 1)//非默认值
            getResources();
        super.onConfigurationChanged(newConfig);
    }

    @Override
    public Resources getResources() {

        Resources res = super.getResources();
        if (res.getConfiguration().fontScale != 1) {//非默认值
            Configuration newConfig = new Configuration();
            newConfig.setToDefaults();//设置默认
            res.updateConfiguration(newConfig, res.getDisplayMetrics());
        }
        return res;
    }
  /*  private void registerToWX() {
        //第二个参数是应用在微信开放平台上的AppID
        mWxApi = WXAPIFactory.createWXAPI(this, APP_ID, false);
        // 将该app注册到微信
        mWxApi.registerApp(APP_ID);
    }*/

    private static App sApp;

    public static Context getAppContext() {
        return sApp;
    }

}
